## 以为中心实现对图像的裁剪
import cv2
import itertools
import os
import tqdm
def patchimg(img,cx=330,cy=200,r=210):
    # img = cv2.imread(imgpath)
    # img = cv2.cvtColor(img, cv2.COLOR_BGR2RG
    for x, y in itertools.product(range(0,640), range(0,480)):
        if (x-cx)**2+(y-cy)**2>r**2:
            img[y,x]=255
    return img

if __name__ == "__main__":
    dir = r'E:/pose/datasets/obj_ac/obj_000003/'
    for i in tqdm.tqdm(range(5360, len(os.listdir(f"{dir}JPEGImages")))):
        img = cv2.imread(f'{dir}JPEGImages' + f"\{i}" + ".jpg")
        img = patchimg(img)
        cv2.imwrite(f"{dir}patch\{i:06d}.jpg", img)
        print(f"{i} image has been processed")